//
//  XLEditIndexView.m
//  industry
//
//  Created by xl on 2020/11/27.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLEditIndexView.h"
#import "XLEditIndexViewProtocol.h"
#import "XLEditIndexAdapter.h"
#import "XLEditIndexVC.h"

@interface XLEditIndexView ()<XLEditIndexViewProtocol>

@property (nonatomic, strong) XLTableView *tableView;
@property (nonatomic, strong) XLEditIndexAdapter *adapter;

@end
@implementation XLEditIndexView

- (void)dealloc {
    XLLog(@"XLEditIndexView dealloc");
}

#pragma mark - XLEditIndexViewProtocol
- (void)buildView {
    [self addSubview:self.tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(self);
    }];
    
    [_adapter setAdapterArray:[(XLEditIndexVC *)self.baseController indexArr]];
    [_tableView reloadData];
}

#pragma mark - Setter/getter
- (XLTableView *)tableView {
    if (!_tableView) {
        _tableView = [[XLTableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _tableView.backgroundColor = [UIColor whiteBgColor];
        _tableView.delegate = self.adapter;
        _tableView.dataSource = self.adapter;
        _tableView.tableFooterView = [UIView new];
        _tableView.bounces = NO;
    }
    return _tableView;
}

- (XLEditIndexAdapter *)adapter {
    if (!_adapter) {
        _adapter = [[XLEditIndexAdapter alloc] init];
    }
    return _adapter;
}
@end
